package com.hecore.lagou.work.oneReducer;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @Author: hecore
 * @Date: 2020/10/19 00:50
 * @Description:  两个Mapper处理
 *   第一个key-value:偏移量&文本
 *   第二个key-value:获取数值 key:key 按默认排序
 */

public class OneReducerMapper extends Mapper<LongWritable, Text, IntWritable, IntWritable> {

    /**
     * 由于每行只有一个数据,所以不需要切割
     * @param key
     * @param value
     * @param context
     * @throws IOException
     * @throws InterruptedException
     */
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        IntWritable intWritable = new IntWritable(Integer.parseInt(value.toString()));
        context.write(intWritable, intWritable);
    }
}
